Page({
  data: {
    animation: {},
  },
  onLoad: function () {
    // // 音频播放
    // const innerAudioContext = wx.createInnerAudioContext()
    // innerAudioContext.autoplay = true
    // innerAudioContext.src = 'https://m801.music.126.net/20190823021111/885ed30caca1a007180abfe04fbfb654/jdyyaac/0609/535c/0f0c/1c17a011bbd61c18c1478f8423bcad64.m4a'
    // innerAudioContext.onPlay(() => {
    //   console.log('开始播放')
    // })
    //
    // innerAudioContext.onError((res) => {
    //   console.log(res.errMsg)
    //   console.log(res.errCode)
    // })
  },

  onShow: function () {
    // 1: 创建动画实例animation:
    var animation = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease',
    })
    this.animation = animation
    var next = true;
    //连续动画关键步骤
    setInterval(function () {
      //2: 调用动画实例方法来描述动画
      if (next) {
        animation.translateX(4).step();
        animation.rotate(19).step()
        next = !next;
      } else {
        animation.translateX(-4).step();
        animation.rotate(-19).step()
        next = !next;
      }
      //3: 将动画export导出，把动画数据传递组件animation的属性 
      this.setData({
        animation: animation.export()
      })
    }.bind(this), 300)
  },
})